<?php

class Admin_UserController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        $user = new Admin_Model_DbTable_Users();
        $this->view->users = $user->fetchAll();
    }

    public function addAction()
    {
        $form = new Admin_Form_User();
        $this->view->form = $form;
        
        if ($this->getRequest()->isPost()){
        	$formData = $this->getRequest()->getPost();
        	if($form->isValid($formData)){
        		$name = $form->getValue('name');
        		
        		$user = new Admin_Model_DbTable_Users();
        		$user->addUser($name);
        		
        		$this->_redirect('admin/user');
        	}else {
        		$form->populate($formData);
        	}
        }
    }


}



